package com.zhava.crawler.domain.model;

import com.zhava.crawler.domain.enums.OutputFormatEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

/**
 * 爬虫领域实体
 *
 * @author zhaxiang
 */
@Data
@NoArgsConstructor
public class Crawler {

    private String url;
    private Integer depth;
    private Boolean extractLinks;
    private Map<String, String> headers;
    private Integer connectTimeout;
    private Integer readTimeout;
    private String cssSelector;
    private OutputFormatEnum outputFormat;
    private Integer exportFile;

    // 爬取结果
    private String rawContent;
    private Integer statusCode;
    private Object extractedData;
    private List<String> links;
    private Long executionTime;
    private Map<String, String> metadata;
    private String errorMessage;

    /**
     * 执行爬取逻辑
     * 
     * @return 是否成功爬取
     */
    public boolean execute() {
        // 在这里实现领域逻辑，通常会调用仓储层或其他服务
        // 实际实现将由基础设施层处理
        return true;
    }

    /**
     * 提取特定内容
     * 
     * @param selector CSS选择器
     * @return 提取的内容
     */
    public Object extract(String selector) {
        // 提取逻辑
        return null;
    }
} 